//package company.permissionsystem.security.auth;
//
//
//import com.alibaba.druid.pool.vendor.SybaseExceptionSorter;
//import company.permissionsystem.security.dao.UserDetailsDao;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.stereotype.Component;
//import org.springframework.util.AntPathMatcher;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import java.util.List;
//
//@Component("rabcService")
//public class MyRBACService {
//
//    private AntPathMatcher antPathMatcher = new AntPathMatcher();
//
//    @Resource
//    private UserDetailsDao userDetailsDao;
//
//    /**
//     *  判断用户是否具有该request资源访问权限
//     * */
//    public boolean hasPermission(HttpServletRequest request, Authentication authentication){
//
//        Object principal = authentication.getPrincipal();
//
//        if(principal instanceof UserDetails){
//            String username = ((UserDetails)principal).getUsername();
//            List<String> urls = userDetailsDao.findAuthortyByUserName(username);
//
//            System.out.println(request.getRequestURI());
//            System.out.println(urls);
//            return urls.stream().anyMatch(
//                    url -> antPathMatcher.match(url,request.getRequestURI())
//            );
//        }
//        return false;
//    }
//
//}
